from typing import *


class Solution:
    def maximumPrimeDifference(self, nums: List[int]) -> int :

        def prime_list(limit: int):
            arr = [[True] for _ in range(limit)]
            ans = []
            for i in range(2, limit):
                if arr[i]:
                    ans.append(i)
                for j in ans:
                    if i * j >= limit:
                        break
                    arr[i * j] = False
                    if i % j == 0:
                        break
            return ans

        s = set(prime_list(101))
        l, r = 0, len(nums) - 1
        for i in range(len(nums)):
            if nums[i] in s:
                l = i
                break
        for i in range(r, -1, -1):
            if nums[i] in s:
                r = i
                break
        return r - l


def prime_list(limit: int):
    arr = [[True] for _ in range(limit)]
    ans = []
    for i in range(2, limit):
        if arr[i]:
            ans.append(i)
        for j in ans:
            if i * j >= limit:
                break
            arr[i * j] = False
            if i % j == 0:
                break
    return ans


print(prime_list(20))


def prime_list(limit: int):
    arr = [[True] for _ in range(limit)]
    ans = []
    for i in range(2, limit):
        if arr[i]:
            ans.append(i)
        for j in range(i * i, limit, i):
            arr[j] = False
    return ans


print(prime_list(20))
